package com.yingda.electronicscaleadvices.activity.login;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.alibaba.fastjson.JSON;

import com.hjq.toast.ToastUtils;
import com.yingda.electronicscaleadvices.MyAPP;
import com.yingda.electronicscaleadvices.R;
import com.yingda.electronicscaleadvices.eventbus.EventBus;
import com.yingda.electronicscaleadvices.manege.BaseActivity;
import com.yingda.electronicscaleadvices.net.Common;
import com.yingda.electronicscaleadvices.utils.SharedPreferenceUtil;
import com.yingda.electronicscaleadvices.utils.StatusBarUtil;

import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

public class SplishActivity extends BaseActivity {

    @BindView(R.id.ll_base)
    RelativeLayout ll_base;
    private String token;
    public static final String TAG = "SplishActivity";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_splish);

        ButterKnife.bind(this);
        //设置背景标题
        StatusBarUtil.showTransparentStatusBarPadding(this, ll_base);

        addActivity(this);
        EventBus.getDefault().register(this);


//
//        token = SharedPreferenceUtil.getInstance(MyAPP.getInstance()).getString("loginToken");
//        //还没有登录
//        if (TextUtils.isEmpty(token)){
//            mHandler.postDelayed(() -> {
//                Intent intent = new Intent(this,LoginActivity.class);
//                startActivity(intent);
//                finish();
//            },3000);
//
//        }else {
//            //显示进度条
//
//        }

    }

    //初始化人脸特征值
    public void initFaceEigenvalue() {
        showWaitingDlg();
        mDialog.setText("人脸图库加载中\n请稍等....");
    }

    @Override
    protected void handleActMessage(Message msg) {
        super.handleActMessage(msg);
        String info = (String) msg.obj;
        switch (msg.what) {
            case Common.Interface_err:
                ToastUtils.show(info);
                //显示 没有授权
                dismissWaitingDlg();
                break;
            case Common.Interface_success:

                break;
            case Common.Interface_No_Authorization:
                ToastUtils.show(info);
                //没有授权

                finish();
                break;
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        removeActivity(this);
        EventBus.getDefault().unregister(this);
    }
}
